<div class="container-fluid col-lg-10 col-xl-8 py-5">
    <div class="row">
        <div class="col-12">
            <h2> {{ $team->name }}</h2>
            <p> {{ $team->description}}</p>
        </div>
        <div class="col-3">
            <div class="row mb-3">
                <div @class(['col-12', 'bg-primary bg-opacity-10' => ($view == 'main')])>
                    <button class="btn btn-link text-decoration-none" wire:click="switchView('main')">Главное</button>
                </div>
                <div @class(['col-12', 'bg-primary bg-opacity-10' => ($view == 'chat')])>
                    <button class="btn btn-link text-decoration-none" wire:click="switchView('chat')">Чат команды</button>
                </div>
                <div @class(['col-12', 'bg-primary bg-opacity-10' => ($view == 'users')])>
                    <button class="btn btn-link text-decoration-none" wire:click="switchView('users')">Участники
                    </button>
                </div>
                <div @class(['col-12', 'bg-primary bg-opacity-10' => ($view == 'links')])>
                    <button class="btn btn-link text-decoration-none" wire:click="switchView('links')">Ссылки
                    </button>
                </div>
                <div @class(['col-12', 'bg-primary bg-opacity-10' => ($view == 'tasks')])>
                    <button class="btn btn-link text-decoration-none" wire:click="switchView('tasks')">Задачи
                    </button>
                </div>
            </div>
        </div>
        <div class="col-9">
            @if( $view == 'main')
                <div class="row">
                    <div class="col-12">
                        Domain message
                    </div>
                </div>
            @endif
            @if( $view == 'chat')
                @livewire('chat-window', ['chatMessages' => $team->chatMessages])
            @endif
            @if( $view == 'users')
                <div class="row">
                    <div class="col-12 mb-3">
                        <input type="text" class="form-control" placeholder="Поиск.." id="searchString"
                               wire:model="searchString">
                    </div>
                    @foreach($team->users->filter(function ($value, $key, ) use ($searchString) { return str_contains($value->user_name, $searchString); })->all() as $user)
                        @livewire('user-list-item', ['user' => $user], key('user - ' . $user->id))
                    @endforeach
                </div>
            @endif
            @if( $view == 'links')
                <div class="row">
                    <div class="col-12 mb-3">
                        <input type="text" class="form-control" placeholder="Поиск.." id="searchString"
                               wire:model="searchString">
                    </div>

                    @livewire('team-link-add-form', ['team' => $team])

                    @foreach($team->links->filter(function ($value, $key) use ($searchString) { return str_contains($value->name, $searchString); })->all() as $link)
                        @livewire('link-list-item', ['link' => $link], key('link-' . $link->id))
                    @endforeach
                </div>
            @endif
                @if( $view == 'tasks')
                    <div class="row">
                        <div class="col-12 mb-3">
                            <input type="text" class="form-control" placeholder="Поиск.." id="searchString"
                                   wire:model="searchString">
                        </div>
                        @foreach($team->tasks->filter(function ($value, $key) use ($searchString) { return str_contains($value->name, $searchString); })->all() as $task)
                            @livewire('task-list-item', ['task' => $task], key('task-' . $task->id))
                        @endforeach
                    </div>
                @endif
        </div>
    </div>
</div>
